package com.example.personalizededucationsystem.dto.dto;

import com.example.personalizededucationsystem.model.User;
import lombok.Getter;
import lombok.Setter;

import java.time.Instant;

@Setter
@Getter
public class UserDetailResponseDto {
    private Long userId;
    private String avatar;
    private String username;
    private String nickname;
    private String email;
    private User.Role role;
    private boolean isActive;
    private User.Subscription subscription;
    private String backgroundUrl;
    private Instant createdAt;

    public static UserDetailResponseDto fromEntity(User user) {
        UserDetailResponseDto dto = new UserDetailResponseDto();
        dto.setAvatar(user.getAvatar());
        dto.setUserId(user.getUserId());
        dto.setUsername(user.getUsername());
        dto.setNickname(user.getNickname());
        dto.setEmail(user.getEmail());
        dto.setRole(user.getRole());
        dto.setActive(user.isEnabled());
        dto.setSubscription(user.getSubscription());
        dto.setBackgroundUrl(user.getBackgroundUrl());
        dto.setCreatedAt(user.getCreatedAt());
        return dto;
    }

}